package com.example.controller;

import com.example.pojo.Device;
import com.example.pojo.PageBean;
import com.example.pojo.Result;
import com.example.service.DeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;

@RestController
@RequestMapping("/device")
public class DeviceController {
    @Autowired
    private DeviceService deviceService;

    @GetMapping
    public Result page(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer pageSize,
                       String deviceid, String note) {
        PageBean pageBean = deviceService.page(page, pageSize,deviceid,note);
        return Result.success(pageBean);
    }

    @PostMapping
    public Result add(@RequestBody Device device){
        deviceService.add(device);
        return Result.success();
    }
    @PutMapping
    public Result update(@RequestBody Device device){
        deviceService.update(device);
        return Result.success();
    }
}
